package study.nzy.com.studydemo;

import android.app.Activity;
import android.support.v7.app.AppCompatActivity;
import android.os.Bundle;
import android.view.View;
import android.widget.AdapterView;
import android.widget.ArrayAdapter;
import android.widget.ListView;

import study.nzy.com.studydemo.utils.ToastUtils;
import study.nzy.com.studydemo.utils.ToastUtils;

public class ListActivity extends Activity {


    ListView lv_fruits;
    String fruitName[]={"苹果","香蕉","樱桃","葡萄","芒果","桔子","梨","菠萝","草莓"};
    Activity activity;

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        activity = this;
        setContentView(R.layout.activity_list);

        lv_fruits = findViewById(R.id.lv_fruits);
//        ArrayAdapter arrayAdapter = new ArrayAdapter(this,android.R.layout.simple_dropdown_item_1line,fruitName);
//        lv_fruits.setAdapter(arrayAdapter);
        lv_fruits.setOnItemClickListener(new AdapterView.OnItemClickListener() {
            @Override
            public void onItemClick(AdapterView<?> adapterView, View view, int i, long l) {
                ToastUtils.showToast(activity,fruitName[i]);
            }
        });



    }
}